#[warn(dead_code)]
pub struct User {
    name: &'static str,
    health: u8,
    max_health: u8,
    attack: u8,
    deffend: u8,
    coins: u8,
}

impl User {
    pub fn create_user() -> User {
        User {
            name: "user",
            health: 10,
            max_health: 10,
            attack: 2,
            deffend: 1,
            coins: 0,
        }
    }
    pub fn say_hello(&self) {
        println!(
            "Hello, my name is {} and i have {} coins",
            self.name, self.coins
        );
    }
    pub fn get_coin(&mut self, coin: u8) -> Result<u8, u8> {
        match self.have_money(coin) {
            Ok(n) => {
                self.coins -= n;
                Ok(coin)
            }
            Err(err) => {
                println!("{}", err);
                Err(0u8)
            }
        }
    }

    fn have_money(&self, coin: u8) -> Result<u8, &str> {
        if self.coins >= coin {
            Ok(coin)
        } else {
            Err("I don't have money")
        }
    }

    pub fn _attack(&self) -> u8 {
        self.attack
    }
    pub fn _deffend(&self) -> u8 {
        self.deffend
    }
    pub fn _healing(&mut self, hil: u8) {
        if self.health >= self.max_health {
            println!("I am full");
        } else {
            self.health += hil;
            println!("heal");
        }
    }
}
